#pragma once

#include "UMLLabel.h"


namespace uml {

const QString UMLLabel::text_default_ = "";
UMLLabel::UMLLabel(const QString& umlType)
    : UMLShape(umlType) {}

void UMLLabel::fromJson(const QJsonObject& json, QStringList& errorList) {
    if (json.isEmpty()) {
        return;
    }

    UMLShape::fromJson(json, errorList);
    text_ = json.value("text").toString(text_default_);
}

void UMLLabel::toJson(QJsonObject& json) {
    UMLShape::toJson(json);
    if (text_ != text_default_) {
        json.insert("text", text_);
    }
}

/// <summary>
/// text getter
/// String to be rendered.
/// </summary>
QString UMLLabel::text() const {
    return text_;
}

/// <summary>
/// text setter
/// String to be rendered.
/// </summary>
void UMLLabel::setText(const QString& value) {
    text_ = value;
}

} // namespace uml
